/**
 * tv视频详情播放页面
 * 
 * @author tanggf
 */
$(function() {
	show_detail.run();
});

var show_detail = {
	run : function() {
		this.__init__();
		this._start_();
		this._get_recent_releases();
		this._bind_events();
		this.itemUrl = $("#itemUrl").val();
		this.title = $("#title").val();
	},

	__init__ : function() {
		this.contextPath = $("#contextPath").val() || "";
		this.category = encodeURIComponent($("#category").val());
	},

	_start_ : function() {
		share.run();
	},
	_get_recent_releases : function() {

		var url = this.contextPath + "/video/movie/othergame";
		$.get(url, function(result) {
			$("#new_release_div").html(result);
		});
	},

	_bind_events : function() {
		// play now btn
		$("#play_btn").click(function() {
			var title = show_detail.title;
			_gaq.push([ '_trackEvent', 'game&sport', 'Play', title ]);
			window.open(show_detail.itemUrl);
		});
		$("#download_btn").click(function() {
			var title = show_detail.title;
			_gaq.push([ '_trackEvent', 'game&sport', 'Download', title ]);
			vdownloader(show_detail.itemUrl, show_detail.title);
		});

	}
};

var share = {
	run : function() {
		// share btn
		$("#share_btn").click(function() {
			$("#share_fb_div").slideToggle();
			$("#share_fb_div > span.share-close").click(function() {
				$("#share_fb_div").slideUp();
			});
		});

		var url = location.href;
		$("#share_input").val(url);

		$("#fb_share_a").click(function() {
			var fbUrl = "https://www.facebook.com/sharer.php?u=" + encodeURIComponent(url);
			_gaq.push([ '_trackEvent', 'Show', 'fb_share', url ]);
			window.open(fbUrl);
		});

		$("#tw_share_a").click(function() {
			var twUrl = "https://twitter.com/share?url=" + encodeURIComponent(url);
			_gaq.push([ '_trackEvent', 'Show', 'twitter_share', url ]);
			window.open(twUrl);
		});
	}
};
